<?php
	if ((!defined("ADMIN-AREA")) || (!in_array(SHOWVIEW,$_SESSION['access']))) {
		die("No data");
	} else {
		unset($_SESSION['access']);
	}

	include "modul/funct_stat.php"; 

	if (ACT=="edit") {
		$kode = (int) $_GET['kode'];
		$sql1 = "SELECT * FROM tbl_login WHERE `id_user`='".$kode."' LIMIT 1";
		$qry1 = mysql_query($sql1);
		while ($row1 = mysql_fetch_object($qry1)) {
			$id_user = $row1->id_user;
			$alias = $row1->alias;
			$namauser = $row1->namauser;
			$passuser = $row1->passuser;
			$typeuser = $row1->type_user;
			$aktivasi = $row1->aktivasi;
		};
		$form_stat = "Edit";
		$cekAdmin = 'readonly="readonly"';
		
		$sql = "SELECT * FROM x_fieldvalue WHERE id_user='".$kode."'";
		$qry = mysql_query($sql);
		$data = array();
		while ($row = mysql_fetch_object($qry)) {
			$data[] = $row->fieldvalue;
		}
	} else {
		$form_stat = "Input";
	}
		
	if ((ACT=="tambah") || (ACT=="edit")) {
?> 
<form name="form1" method="post" action="<?php echo $path; ?>ver_user.php?show=<?php echo SHOW; ?>&showview=<?php echo SHOWVIEW; ?>" onsubmit="MM_validateForm('<?php echo $USER_NAME; ?>','','R','<?php echo $USER_ALIAS; ?>','','R');return document.MM_returnValue">
  <table width="550" border="0" align="center" cellpadding="4" cellspacing="2" class="imagesSUB">
    <tr valign="middle"> 
      <th height="30" colspan="3" class="imagesSUB"> <div align="center"><?php echo $USER_ID; ?></div></th>
    </tr>
    <tr valign="top"> 
      <th nowrap="nowrap"> <div align="right"><?php echo $USER_NAME; ?></div></th>
      <td> <div align="center">:</div></td>
      <td> <div align="left"> 
          <input name="namauser" type="text" id="<?php echo $USER_NAME; ?>" size="30" maxlength="50" value="<?php echo $namauser; ?>">
        </div></td>
    </tr>
    <tr valign="top">
      <th nowrap="nowrap"> <div align="right"><?php echo $USER_PASSWORD; ?></div></th>
      <td><div align="center">:</div></td>
      <td><div align="left">
        <input name="katakunci" type="password" id="<?php echo $USER_PASSWORD; ?>" size="25" maxlength="25" />
        <?php
		  	if (ACT=="edit") {
		  ?>
        <br />
        <font color="#990000"><?php echo $USER_TIPS_EDIT_PASS; ?></font>
        <?php
		  	}
		  ?>
      </div></td>
    </tr>
    <tr valign="top">
      <th nowrap="nowrap"> <div align="right"><?php echo $USER_VER_PASS; ?></div></th>
      <td><div align="center">:</div></td>
      <td><div align="left">
        <input name="katakuncilagi" type="password" id="<?php echo $USER_VER_PASS; ?>" size="25" maxlength="25" />
      </div></td>
    </tr>
    <tr valign="middle">
      <th height="30" colspan="3" class="imagesSUB"> <div align="center"><?php echo $USER_BIO; ?></div></th>
    </tr>
    <tr valign="top">
      <th nowrap="nowrap"> <div align="right"><?php echo $USER_ALIAS; ?></div></th>
      <td><div align="center">:</div></td>
      <td><div align="left">
        <input name="alias" type="text" id="<?php echo $USER_ALIAS; ?>" size="40" maxlength="25" value="<?php echo $alias; ?>" />
      </div></td>
    </tr>
<?php
	echo $queryData->x_field("","detail_user","",$id_user,"",false,'align="right" style="font-weight:bold"',2);
?>
    <tr valign="middle">
      <th height="30" colspan="3" class="imagesSUB"> <div align="center"><?php echo $USER_ACCESS; ?></div></th>
    </tr>										
    <tr valign="top"> 
      <th nowrap="nowrap"> <div align="right"><?php echo $USER_GROUP; ?></div></th>
      <td width="2%"> <div align="center">:</div></td>
      <td width="76%"> <div align="left"> 
          <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" class="login">
            <?php

		$sql1 = "SELECT * FROM tbl_hakakses WHERE aktivasi='1'";
		$qry1 = mysql_query($sql1);
		while ($row1 = mysql_fetch_object($qry1)) {
			$sqlQ = "SELECT * FROM tbl_login WHERE id_user='".$id_user."'";
			$qryQ = mysql_query($sqlQ);
			$rowQ = mysql_fetch_object($qryQ);
			$type_user = explode("[break]",$rowQ->type_user);
?>
            <tr valign="top"> 
              <td width="10" height="20"><input name="type[]" type="checkbox" id="type[]" value="<?php echo $row1->tipe; ?>"
			<?php if (in_array($row1->tipe,$type_user))
			  	echo "checked";
			?>
			   /></td>
              <td width="125" valign="middle" nowrap="nowrap"><?php echo $row1->tipe; ?></td>
              <td width="5" valign="middle">:</td>
              <td valign="middle" nowrap="nowrap"><?php echo $row1->alias; ?></td>
            </tr>
<?php
		}		
?>          </table>
      </div></td>
    </tr>
    <tr valign="top">
      <th valign="top" nowrap="nowrap"> <div align="right"><?php echo $USER_STATUS; ?></div></th>
      <td valign="top"><div align="center">:</div></td>
      <td valign="top"><div align="left">
        <?php if ($aktivasi==1) { 
		  		$data1 = "checked";
			} else {
				$data2 = "checked";
			}
		  ?>
        <input type="radio" name="aktivasi" value="1" <?php echo $data1; ?> />
        <?php echo $DEV_ACTIVE; ?>
        <input type="radio" name="aktivasi" value="0" <?php echo $data2; ?> />
        <?php echo $DEV_NO_ACTIVE; ?></div></td>
    </tr>
    <tr valign="top"> 
      <th colspan="3"> <div align="center"></div></th>
    </tr>
    <tr valign="top"> 
      <th>&nbsp;</th>
      <td>&nbsp;</td>
      <td><div align="left">
        <input type="submit" name="submit" id="submit" value="<?php echo $DEV_CTRL_SUBMIT; ?>" />
          <input type="reset" name="Reset" value="<?php echo $DEV_CTRL_RESET; ?>" />
          <input name="kode" type="hidden" id="kode" value="<?php echo $kode; ?>">
          <input name="status" type="hidden" id="status" value="<?php echo ACT; ?>">
      </div></td>
    </tr>
  </table>
</form>
<?php
	} else {
		echo $queryData->cari_form($USER_SEARCH);
		$caridata = $queryData->cari_padaku("namauser","alias");
		
		if (isset($_SESSION['isroot'])) {
			$sql1 = "SELECT id_user,namauser,alias,aktivasi,type_user,tanggal,tglupdate FROM tbl_login WHERE 1 ".$caridata." ORDER BY tanggal DESC LIMIT ".$limitdown.",10";
		} else {
			$sql1 = "SELECT id_user,namauser,alias,aktivasi,type_user,tanggal,tglupdate FROM tbl_login WHERE ".RUSER." ".$caridata." ORDER BY tanggal DESC LIMIT ".$limitdown.",10";
		}
		//echo $sql1;
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><table border="0" align="center" cellpadding="4" cellspacing="2" class="imagesSUB">
		<tr>
        <th height="30" nowrap="nowrap" class="imagesSUB"><div align="center"><?php echo $USER_NAME; ?> - <?php echo $USER_ALIAS; ?></div></th>
        <th nowrap="nowrap" class="imagesSUB"><div align="center"><?php echo $USER_GROUP; ?></div></th>
        <th nowrap="nowrap" class="imagesSUB"><div align="center"><?php echo $USER_DATE; ?></div></th>
        <th nowrap="nowrap" class="imagesSUB"><div align="center"><?php echo $USER_UPDATE; ?></div></th>
        <th nowrap="nowrap" class="imagesSUB"><div align="center"><?php echo $USER_STATUS; ?></div></th>
        <th width="50" nowrap="nowrap" class="imagesSUB"><div align="center"><?php echo $DEV_ACTION; ?></div></th>
      </tr>
      <?php		
		$qry1 = mysql_query($sql1);
		$numrow = mysql_num_rows($qry1);
		$num = 1;
		$x = 1;
		if ($numrow==0) {
			echo '<tr><th colspan="6">'.$DEV_NO_DATA.'</th></tr>';
		} else {
			while ($row1 = mysql_fetch_object($qry1)) {
				$data = $x % 2;
				if ($data==0) {
					$dataX = "ganjil";
				} else {
					$dataX = "genap";
				} 
?>
	  <tr valign="top" class="<?php echo $dataX; ?>" onmouseover="setBG('bg<?php echo $x; ?>','#FFFFDD')" onmouseout="setBG('bg<?php echo $x; ?>','')" id="bg<?php echo $x; ?>"> 
        <td nowrap="nowrap"><div align="left"><?php echo $row1->namauser." - ".$row1->alias; ?></div></td>
        <td><div align="center">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="login">
              <tr>
                <td width="6%">&nbsp;</td>
                <td width="94%"><?php
			$data = explode("[break]",$row1->type_user);
			foreach($data as $value => $nilai) {
				if (($nilai=="0") || ($nilai)) {
					echo $nilai." ";
				}
			 } 
 ?>                </td>
              </tr>
            </table>
        </div></td>
        <td><div align="center"><?php echo $queryData->tanggalan($row1->tanggal,false,false,true); ?></div></td>
        <td><div align="center">
          <?php echo $queryData->tanggalan($row1->tglupdate,false,false,true); ?>
        </div></td>
        <td><div align="center">
          <?php ($row1->aktivasi=="1") ? print "<img src=\"".$dev_path."images/ico_check.gif\" width=\"16\" height=\"16\"></div></td>" : print "<img src=\"".$dev_path."images/ico_delete.gif\" width=\"16\" height=\"16\"></div></td>"; ?>
        </div></td>
		<?php 
		if ($row1->id_user=='1') {
			echo $queryData->ctrl_data('','index.php?show='.SHOW.'&showview='.SHOWVIEW.'&act=edit&kode='.$row1->id_user,''); 
		} else { 
        	echo $queryData->ctrl_data('','index.php?show='.SHOW.'&showview='.SHOWVIEW.'&act=edit&kode='.$row1->id_user,$path.'ver_user.php?show='.SHOW.'&amp;showview='.SHOWVIEW.'&amp;kode='.$row1->id_user.'&amp;act_ver=Hapus'); 
		}
			?>
      </tr>
      <?php 
				$num++;
				$x++;
			}  		
		}
?>
    </table></td>
  </tr>
</table>
<div align="center"><?php echo $queryData->next_prev($num,$pages_syarat,$limitdown); ?></div>
<?php
	}
?>
